![]() |
||||
Working With Lists - Continued |
||||
OPENING QUESTIONS: Please take a look at the following code. They both end with the same result, but the way they work is substantially different.
Work with your team to determine what circumstances you might use Code A and what circumstances Code B would be more appropriate. LEARNING TARGET: ROOKIES: I will be able to complete a brief program that allows a user to add a name to an existing list. I will begin working on adding code to that program that allows a user to see if a word exists in a list, and if it does, prompts the user to delete (or NOT!) that word from the list. SENSEIS: I will finish working on a program that allows my user to add, delete or check to see if a word exists in a list. I will begin working on an option to that program that allows a user to select whether they want the list sorted alphabetically from A - Z or from Z to A. WORK O' THE DAY: We talked at length yesterday about moving through a list -- a process that is called 'iterating' through a list or just plain 'iteration' ═══════════════════════════
Notice how similar that is to Code A above:
═══════════════════════════ HERE is the code for both A and B. Be sure and make a copy of that AND Save it. Now please use Code A as a basis for writing a program that allows a user to type a planet, check to see if it is there and then either:
there is a quicker and easier way to do that, but I want you to practice 'iterating' which is to say 'stepping' through the list with code and examining each element of that array in turn. Senseis: Please work on asking your user to enter a planet name. Prompt them to enter a planet until all 8 planet names are successfully entered. Duplicates are not allowed. That means that Mars, MARS, mars are not allowed. Only one entry for any form of Mars is allowed. Once all 8 planet names are entered, then prompt the user if they want to quit or if they want to sort the list the list from A - Z or sort the list from Z - A. |
||||